package W072_081.src.dao;

import W072_081.src.entity.School;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class SchoolDao {
    public boolean add(Connection connection, School school) throws SQLException {
        // 准备预编译的语句
        String sql_insert = "INSERT INTO school (description, no, remarks) VALUES (?, ?, ?)";
        PreparedStatement pstmt_update = connection.prepareStatement(sql_insert);
        pstmt_update.setString(1, school.getDescription());
        pstmt_update.setString(2, school.getNo());
        pstmt_update.setString(3, school.getRemarks());
        // 执行预编译语句，影响的行数保存在rowAffected中
        int rowAffected = pstmt_update.executeUpdate();
        return rowAffected > 0;
    }
}